#ifndef _SPISERVICE_NETWORK_SERVICEINTERFACE_SPIDEV_SPIDEVX3_H_
#define _SPISERVICE_NETWORK_SERVICEINTERFACE_SPIDEV_SPIDEVX3_H_

#include "Spi_Dev_Management/ISpi_Dev.h"
#include <map>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/time.h> 
#include <linux/ioctl.h>
#include <sys/stat.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>

class Spi_Dev_X3 : public ISpi_Dev
{
public:
    Spi_Dev_X3(const std::string& node);
    ~Spi_Dev_X3()  override = default;

    bool open_dev() override;
    bool init_dev(uint32_t speed, uint16_t mode, uint8_t bits, uint16_t delay, bool verbose = false) override;
    void close_dev() override;

    bool send_msg() override;
    bool recv_msg() override;
    bool transfer(uint8_t const *tx, uint8_t const *rx, size_t len) override;
    const std::string& node_name() const;

private:
    int         its_spi_dev_fd;
    std::string its_spi_node;
    uint32_t    its_speed;
    uint16_t    its_delay;
    uint32_t    its_mode;
    uint8_t     its_bits;
    bool        is_verbose;
};

#endif